package logic

import (
	"context"
	"zhaowei/baidurpc/baidurpc"
	"zhaowei/baidurpc/internal/svc"
	"zhaowei/models/mysql"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowLogic) Show(in *baidurpc.ShowRequest) (*baidurpc.ShowResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.Post
	mysql.DB.Debug().Where("user_id = ?", in.UserId).Where("id = ?", in.Id).Find(&user)

	return &baidurpc.ShowResponse{
		Id:     int64(user.ID),
		UserId: int64(user.UserId),
		Name:   user.Name,
		Image:  user.Image,
		Like:   int64(user.Like),
		BarId:  int64(user.BarId),
	}, nil
}
